#include<stdio.h>
#include<string.h>  //使用strlen
#define P1 "This is a string."
#define P2 "That is a parament.Successful！"
#define width 56
#define space ' '

void show_n_char(char ch, int num);
void show_mid(char* ch, int num);   //char ch  改 char* ch 定义一个字符串

int main(void)
{

   /*②*/ 
    show_n_char('*', width);
    printf("\n");
    show_mid(P1, width);
    show_mid(P2, width);

    /*①*/
    // P1space = (width - strlen(P1)) / 2;
    // show_n_char(space, P1space);
    // printf("%s", P1);
    // P1space1 = width - P1space - strlen(P1);
    // show_n_char(space, P1space1);
    // printf("\n");

    // P2space = (width - strlen(P2)) / 2;
    // show_n_char(space, P2space);
    // printf("%s", P2);
    // P2space1 = width - P2space - strlen(P2);
    // show_n_char(space, P2space1);
    // printf("\n");

    /****************/
    show_n_char('*', width);
    printf("\n");

    return 0;
}

void show_n_char(char ch, int num)
{
    int count;

    for(count = 0; count < num; count++)
    {
        putchar(ch);
    }
    // putchar('\n');
}

void show_mid(char* ch, int num)
{
    int PspaceBef, PspaceBeh;

    PspaceBef = (num - strlen(ch)) / 2;
    show_n_char(space, PspaceBef);
    printf("%s", ch);
    PspaceBeh = num - PspaceBef - strlen(ch);
    show_n_char(space, PspaceBeh);
    printf("\n");    
}